//
//  ACAlarmController.m
//  AlarmClock
//
//  Created by kai ren on 07/11/2011.
//  Copyright 2011 Renkai. All rights reserved.
//

#import "ACAlarmController.h"

@implementation ACAlarmController

@synthesize notification;
@synthesize isShowing;
@synthesize alarm;

- (id)init{
	if ( self = [super init]) {
		isShowing = NO;
		lblTitle = [[UILabel alloc] initWithFrame:CGRectMake(20, 30, 280, 44)];
		audioPlayer = nil;
	}
	
	return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
	self.view.backgroundColor = Background;
	
	//Alarm Title
	lblTitle.font = [UIFont boldSystemFontOfSize:25];
	lblTitle.textAlignment = UITextAlignmentCenter;
	lblTitle.backgroundColor = [UIColor clearColor];
	
	//Control Button
	btnClose = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	btnClose.frame = CGRectMake(35, 100, 100, 30);
	[btnClose setTitle:NSLocalizedString(@"Shut Down", nil) forState:UIControlStateNormal];
	[btnClose addTarget:self action:@selector(shutDown) forControlEvents:UIControlEventTouchUpInside];
	
	btnSnooze = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	btnSnooze.frame = CGRectMake(185, 100, 100, 30);
	[btnSnooze setTitle:NSLocalizedString(@"Snooze", nil) forState:UIControlStateNormal];
	[btnSnooze addTarget:self action:@selector(snooze) forControlEvents:UIControlEventTouchUpInside];
	
	//Add to View
	[self.view addSubview:lblTitle];
	[self.view addSubview:btnClose];
	[self.view addSubview:btnSnooze];
}

- (void)dealloc {
    [super dealloc];
	
	[lblTitle release];
	[btnClose release];
	[btnSnooze release];
	[audioPlayer release];
}

#pragma mark -
#pragma mark Button Action

- (void)snooze{
	
}

- (void)shutDown{
	[[UIApplication sharedApplication] cancelLocalNotification:notification];
	self.isShowing = NO;
	[self dismissModalViewControllerAnimated:YES];
	[audioPlayer stop];
}

#pragma mark -
#pragma mark Set Method

- (void)setAlarm:(ACAlarm *)newAlarm{
	if (nil != alarm) {
		[alarm release];
	}
	
	alarm = [newAlarm retain];
	
	lblTitle.text = alarm.title;
}

@end

